package com.hd.assistant.dal.dataobject.ordermining;

import java.util.Date;

import com.alibaba.fastjson.JSONObject;
import com.taobao.api.domain.NotifyTopats;
import com.taobao.api.domain.NotifyTrade;

public class NotifyMessage {
	public static String TradeCreate = "TradeCreate";
	public static String TradeModifyFee = "TradeModifyFee";
	public static String TradeClose = "TradeClose";
	public static String TradeSuccess = "TradeSuccess";
	public static String TradeBuyerPay = "TradeBuyerPay";
	
	public static String TradeChanged = "TradeChanged";
	
	public static String TRADE ="trade";
	public static String TOPATS ="topats";
	public static Integer STATUS_INIT = 0;
	public static Integer STATUS_PROCESSED = 1;
	private Long id;
	private String topic;
	private String contentStatus;
	private String message;
	private Integer status;
	private Date gmtModify;
	private Date gmtCreate;
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getTopic() {
		return topic;
	}
	public void setTopic(String topic) {
		this.topic = topic;
	}
	public String getContentStatus() {
		return contentStatus;
	}
	public void setContentStatus(String contentStatus) {
		this.contentStatus = contentStatus;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public Date getGmtModify() {
		return gmtModify;
	}
	public void setGmtModify(Date gmtModify) {
		this.gmtModify = gmtModify;
	}
	public Date getGmtCreate() {
		return gmtCreate;
	}
	public void setGmtCreate(Date gmtCreate) {
		this.gmtCreate = gmtCreate;
	}
	public void launchMessageObject(NotifyTrade trade){
		if(trade == null)
			return;
		this.setTopic(TRADE);
		this.setMessage(JSONObject.toJSONString(trade));
	}
	public void launchMessageObject(NotifyTopats topats){
		if(topats == null)
			return;
		this.setTopic(TOPATS);
		this.setMessage(JSONObject.toJSONString(topats));
	}
	public Object getMessageObject(){
		if(topic==null)
			return null;
		if(topic.equals(TRADE)){
			NotifyTrade trade =(NotifyTrade)JSONObject.parseObject(this.message, NotifyTrade.class);
			return trade;
		}
		if(topic.equals(TOPATS)){
			NotifyTopats topats = (NotifyTopats)JSONObject.parseObject(this.message, NotifyTopats.class);
			return topats;
		}
		return null;
	}

}
